﻿$().ready(function () {
    var $leftMenu = $("#leftmenu");
    var $rightMenu = $("#rightmenu");

    $(window).scroll(function () {
        $leftMenu
				    .stop()
				    .animate({ "marginTop": ($(window).scrollTop() + 90) + "px" }, "slow");

        $rightMenu
				    .stop()
				    .animate({ "marginTop": ($(window).scrollTop() + 90) + "px" }, "slow");

    });

    $("#tiles").sortable({
        revert: true,
        hande: "a.move-button",
        stop: function (event, ui) {
            $(".tile-toolbar", this).hide('fast');
        }
    });

    $(".tile-content").mouseenter(function () {
        $(".tile-toolbar", this).slideToggle('fast');
    }).mouseleave(function () {
        $(".tile-toolbar", this).slideToggle('fast');
    });

    $("#back-button").click(function () {
        $("#tiles").effect("drop", { direction: "right" }, 600);
    });

    $("#save-button").click(function () {

        $("#central").effect("transfer", { to: $("#save-button") }, 600);
    });

    $("#favadd-button").click(function () {
        $("#favs-button").toggleClass("highlight");
        $("#central").effect("transfer", { to: $("#favs-button") }, 1000, function () {
            $("#favs-button").toggleClass("highlight");
        });
    });


    $(".tile-link,.tile-content>h3").click(function () {
        //$("#central").effect("transfer", { to: $("#save-button") }, 600);
    });

    $(".collapser").collapser({
        target: 'next',
        effect: 'slide',
        changeText: false
    });

    $(".noclick").click(function (event) {
        event.stopPropagation();
    });

    $("#version-selector-button,#versions-button").collapser({
        target: '#version-selector-space',
        effect: 'slide',
        changeText: false
    });

    $("#favs-button").collapser({
        target: '#favs-space',
        effect: 'slide',
        changeText: false
    }, function () {
        $('body,html').animate({
            scrollTop: 0
        }, 600);
    });

    $("#add-button").collapser({
        target: '#add-space',
        effect: 'slide',
        changeText: false
    }, function () {
        $('body,html').animate({
            scrollTop: 0
        }, 600);
    });

    $("#prompt-button").collapser({
        target: '#prompt-space',
        effect: 'slide',
        changeText: false
    }, function () {
        $('body,html').animate({
            scrollTop: 0
        }, 600);
    });

});